import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:wangziyi/pages/app_my/app_select_address/setting_address_add.dart';
import 'package:wangziyi/pages/app_my/app_select_address/view.dart';

import 'logic.dart';
import 'state.dart';

class AppAddressPage extends StatelessWidget {
  final AppAddressLogic logic = Get.put(AppAddressLogic());
  final AppAddressState state = Get.find<AppAddressLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(

      appBar: AppBar(
        title: Text('我的收货地址'),
        centerTitle: true,
      ),
      body: Container(
        color:  Color(0xff66dedede),
        child: ListView.builder(
            itemBuilder: (context, index) {
              return Container(

                margin: EdgeInsets.all(10),
                decoration: BoxDecoration(
                color: Colors.white,
                  borderRadius: BorderRadius.all(Radius.circular(20))
                ),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    ListTile(
                      leading: Container(
                        height: 50,
                        width: 50,
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.all(Radius.circular(50)),
                          color: Color(0XFFFBE9E7),
                        ),
                        child: Container(
                            padding: EdgeInsets.all(5),
                            child: Center(
                                child: Text(
                                  '王子怡'[0],

                                  style: TextStyle(
                                      fontWeight: FontWeight.w900,
                                      fontSize: 16,
                                      color: Colors.deepOrange),
                                ))),
                      ),
                      title: Row(
                        children: [
                          Text("王子怡",
                              maxLines: 1,
                              style: TextStyle(
                                  fontWeight: FontWeight.w900, fontSize: 20)),
                          SizedBox(
                            width: 10,
                          ),
                          Text('16666666666666',
                              maxLines: 1,
                              style: TextStyle(
                                  fontWeight: FontWeight.w700,
                                  fontSize: 18,
                                  color: Colors.grey)),
                        ],
                      ),
                      subtitle: Text(
                        'addressTitele[index]',
                        style: TextStyle(color: Colors.black,
                            fontWeight: FontWeight.w900, fontSize: 16),
                      ),
                      trailing: const Icon(
                        Icons.edit_outlined,
                        color: Colors.grey,
                        size: 30,
                      ),
                      isThreeLine: true,
                    ),
                    Divider(height: 1,),
                    Row(
                      children: <Widget>[
                        Expanded(
                            child: RadioListTile<String>(
                              value: "默认地址",
                              title:Text("默认地址"),
                              // groupValue: _newValue,
                              onChanged: (v) {
                              },
                              activeColor: Colors.deepOrange,
                            )),
                        Expanded(
                          child: GestureDetector(
                            child: Align(
                              child: Text("删除"),
                              alignment: Alignment.centerRight,
                            ),
                            onTap: () {
                              return showDialog(
                                  context: context,
                                  builder: (context) {
                                    return AlertDialog(
                                      content: Text(
                                          "确定要删除该地址吗?"),
                                      actions: <Widget>[
                                        FlatButton(
                                          child: Text('取消'),
                                          onPressed: () =>
                                              Navigator.pop(context),
                                        ),
                                        FlatButton(
                                            child: Text('确定'),
                                            onPressed: () {

                                              Navigator.pop(context);
                                            }),
                                      ],
                                    );
                                  });
                            },
                          ),
                        ),
                        SizedBox(
                          width: 20,
                        )
                      ],
                    )
                  ],
                ),
              );
            },
            itemCount: 10),
      ),
      bottomNavigationBar: Container(
        margin: EdgeInsets.all( 20),
        child: MaterialButton(
          shape: RoundedRectangleBorder(
              side: BorderSide.none, borderRadius: BorderRadius.circular(50)),
          height: 50,
          child: Text("添加新地址",style: TextStyle(color: Colors.white),),
          color: Colors.deepOrange,
          onPressed: ()=>Get.to(()=>AppSelectAddressPage()) ,
        ),
      ),
    );
  }
}
